<template>
  <div v-if="block">
    <slot></slot>
    <slot name="footer"></slot>
  </div>
  <el-dialog
      v-else
      width="65vw"
      v-bind="$attrs"
      v-model="showDialog"
      draggable
      :title="title"
      append-to-body
      @closed="_closed"
  >
    <div class="dialogContent">
      <slot></slot>
    </div>
    <template #footer>
      <slot name="footer"></slot>
    </template>
  </el-dialog>
</template>

<script lang="ts">
export default {
  name: 'DialogAndBlock',
  props: {
    block: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: '',
    },
    top: {
      type: String,
      default: '10vh',
    },
  },
  emits: ['closed'],
  data() {
    return{
      showDialog: false,
    }
  },
  methods: {
    _closed() {
      this.$emit('closed')
    },
    open() {
      this.showDialog=true
    },
    close() {
      this.showDialog=false
    }
  }
}
</script>

<style lang="scss" scoped>
.dialogContent{
  max-height: 70vh;
  overflow: auto;
}
</style>